#include "stdio.h"
#include "string.h"
#define left  '<'
#define right '>'

int site[1000];
char s[2000];

int check()
{
    int i,len,flag;
    len=strlen(s);
    flag=0;
    for (i=0;i<len;i++)
    	if (s[i]==left) 
    	{
    	    flag++;
    	    if (flag>1) return 0;
 		}        
 		else if (s[i]==right)
 		{
 		    flag--;
 		    if (flag<0) return 0;
 		}    
	if (flag!=0) return 0;
	return 1;
}    

void delchar()
{
    int i,j,k,len,flag,a,b,d;
    
    flag=1;
    while (flag)
    {
        len=strlen(s);
        flag=0;
        for (i=0;i<len-1;i++)
        	if (s[i]==right && s[i+1]!=left)
        	{
        	    flag=1;
        	    a=i;
        	    break;
        	}    
    	if (flag)
    	{
    	    b=a+1;
    	    while (s[b]!=left) b++;
    	    d=b-a-1;
    	    for (i=a+1;i<=len-d+1;i++)
    	    	s[i]=s[i+d];
    	}    
    }    
}    

void delblank()
{
    int i,len,flag,a,b;
    
    flag=1;
    while (flag)
    {
        flag=0;
        len=strlen(s);
        for (i=0;i<len;i++)
        	if (s[i]==' ')
        	{
        	    if (s[i-2]==left&&s[i-1]=='A') continue;
             	flag=1;
        	    a=i;
        	    break;
        	}    
    	if (flag)
    	{
    	    strncpy(s+i,s+i+1,len-i+1);
    	}    
   // 		for (i=a;i<=len;i++)
   //			s[i]=s[i+1];
		
    }    
}    

int checkht()
{
    char head[30],tail[30];
    int i,len;
    len=strlen(s);
    if (len<14) return 0;
    strncpy(head,s,12);
    head[12]='\0';
    
    strncpy(tail,s+len-14,14);
    tail[14]='\0';
//    printf("%s\n",tail);
    if (strcmp(head,"<HTML><BODY>")!=0) return 0;
    if (strcmp(tail,"</BODY></HTML>")!=0) return 0;
    return 1;
}    

int rmht()
{
    char ss[2000];
    int len;
    len=strlen(s);
    strncpy(ss,s+12,len-26);
    ss[len-26]='\0';
    strncpy(s,ss,sizeof(ss));
 //   printf("testing ...1%s1\n",ss);
}    

void getsite()
{
    int i,len;
    site[0]=0;
    len=strlen(s);
    for (i=0;i<len;i++)
    	if (s[i]==left||s[i]==right)
    		site[++site[0]]=i;
}    

int pushandpop()
{
    int tt[2000],p;
    int i,j,a,b;
    char ch;
    
    tt[0]=-1;
    p=0;
    for (i=1;i<=site[0];i+=2)
    {
        a=site[i];
        b=site[i+1];
        if (b-a==1) return 0;
   		if (b-a==2)
     	{
     	    ch=s[a+1];
     	    if (ch=='B') tt[++p]=1;
     	    else if (ch=='I') tt[++p]=2;
     	    else return 0;
      	}   
      	else if (b-a==3&&s[a+1]=='/')
      	{
      	    ch=s[a+2];
      	    if (ch=='B') 
      	    {
      	        if (tt[p]==1) p--;
      	        else return 0;
      	    }    
      	    else if (ch=='I') 
      	    {
      	        if (tt[p]==2) p--;
      	        else return 0;
      	    }    
      	    else if (ch=='A') 
      	    {
      	        if (tt[p]==3) p--;
      	        else return 0;
      	    }
           	else
            	return 0;    
      	}    
        else
        {
            if (b-a-1<18) return 0;
            a++;   if (s[a]!='A') return 0;
            a++;   if (s[a]!=' ') return 0;
            a++;   if (s[a]!='H') return 0;
            a++;   if (s[a]!='R') return 0;
            a++;   if (s[a]!='E') return 0;
            a++;   if (s[a]!='F') return 0;
            a++;   if (s[a]!='=') return 0;
            a++;   if (s[a]!='h') return 0;
            a++;   if (s[a]!='t') return 0;
            a++;   if (s[a]!='t') return 0;
            a++;   if (s[a]!='p') return 0;
            a++;   if (s[a]!=':') return 0;
            a++;   if (s[a]!='/') return 0;
            a++;   if (s[a]!='/') return 0;
			b--;   if (s[b]!='m') return 0;
			b--;   if (s[b]!='o') return 0;
			b--;   if (s[b]!='c') return 0;
			b--;   if (s[b]!='.') return 0;
			tt[++p]=3;
        }          
    }    
    if (p!=0) return 0;
    return 1;
}    

main()
{
    int n,yes;
    int i,j;
    scanf("%d",&n);
    gets(s);
    while (n-->0)
    {
        memset(site,0,sizeof(site));
        gets(s);
        delblank();
//        delchar();
//        printf("%s\n",s);

		yes=check();
		if (yes) yes=checkht();
		if (yes)
  		{
        	 rmht();
//	      	   printf("%s\n",s);
        	 getsite();
        	 yes=pushandpop();
  		}  	 
		 
  		
//    printf("%d\n",yes);
		if (yes) printf("Syntax Included\n");
		else 	printf("No Syntax Included\n");

  			
    }
    
    return 0;
}    